<!DOCTYPE html>
<html lang="en">
<script language="JavaScript" src="../js/jquery.js" type=""></script>
<head>
    <meta charset="utf-8">
    <title>ECharts 统计</title>
    <!-- 引入 echarts.js -->
    <script src="https://cdn.staticfile.org/echarts/4.3.0/echarts.min.js"></script>
</head>

<body onload="init()" style="position:relative; width: 100%; height: 100%;">
<div id="main" style="position:relative; width: 88%; height: 500px;"></div>
</body>

<script type="text/javascript">
    function getParent_id(){
        var result;
        var url=decodeURI(window.location.search); //获取url中"?"符后的字串
        if(url.indexOf("?") != -1) {
            result = url.substr(url.indexOf("=")+1);
        }
        return result;
    }
    let Child_id=getParent_id();

    function init(){
        alert("开始统计");
        let url="../maturecropModule_file_servlet_action";
        let message={};
        message.Action="statistics_mature_crop_record";
        message.value=Child_id;
        $.post(url,message,function (json){
            if(json.ok===200){
                console.log(json);
                initTable(json);
                alert("统计成功!");
            } else {
                alert("统计失败!");
            }
        });
    }

    function initTable(json){
        let myChart = echarts.init(document.getElementById('main'));
        const option = {
            color: ['#80f4fe'],
            title: {
                text: 'Greenhouse Statistic/收获作物产量统计'
            },
            tooltip: {},
            legend: {
                data: ['作物产量']
            },
            xAxis: {
                data: ["作物总数", "低产量", "中等产量", "高产量", "超高产量"]
            },
            yAxis: {},
            series: [{
                name: '作物产量',
                type: 'bar',
                data: [json.sumNum, json.Low_production, json.Medium_production, json.High_production, json.Ultra_high_production]
            }]
        };
        myChart.setOption(option);
    }
</script>
</html>